/*!
 * \file __frtds_days_fromat.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>
#include "frcomm.h"
#include "frmem.h"

#include "frbyte_buffer.h"
#include "frhex_dump.h"
#include "frlist.h"
#include "frhash2.h"
#include "conntrack.h"
#include "frreport_comm.h"
#include "frct_comm.h"
#include "frtds_convert.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

extern void __frtds_days_fromat(int i_days
        , unsigned int *p_ui_year
        , unsigned int *p_ui_month
        , unsigned int *p_ui_day);

static void __case1(void)
{
    int i_days = 10;
    unsigned int ui_years = 0, ui_month = 0, ui_days = 0;

    __frtds_days_fromat(i_days, &ui_years, &ui_month, &ui_days);

    CU_ASSERT_EQUAL(ui_years, 1900);
    CU_ASSERT_EQUAL(ui_month, 1);
    CU_ASSERT_EQUAL(ui_days, 11);

    return;

}

static void __case2(void)
{
    int i_days = 100;
    unsigned int ui_years = 0, ui_month = 0, ui_days = 0;

    __frtds_days_fromat(i_days, &ui_years, &ui_month, &ui_days);

    CU_ASSERT_EQUAL(ui_years, 1900);
    CU_ASSERT_EQUAL(ui_month, 4);
    CU_ASSERT_EQUAL(ui_days, 11);

    return;

}

static void __case3(void)
{
    int i_days = 1000;
    unsigned int ui_years = 0, ui_month = 0, ui_days = 0;

    __frtds_days_fromat(i_days, &ui_years, &ui_month, &ui_days);

    CU_ASSERT_EQUAL(ui_years, 1902);
    CU_ASSERT_EQUAL(ui_month, 9);
    CU_ASSERT_EQUAL(ui_days, 28);

    return;

}

static void __case4(void)
{
    int i_days = 10000;
    unsigned int ui_years = 0, ui_month = 0, ui_days = 0;

    __frtds_days_fromat(i_days, &ui_years, &ui_month, &ui_days);

    CU_ASSERT_EQUAL(ui_years, 1927);
    CU_ASSERT_EQUAL(ui_month, 5);
    CU_ASSERT_EQUAL(ui_days, 20);

    return;

}

static void __case5(void)
{
    int i_days = 16861;
    unsigned int ui_years = 0, ui_month = 0, ui_days = 0;

    __frtds_days_fromat(i_days, &ui_years, &ui_month, &ui_days);

    CU_ASSERT_EQUAL(ui_years, 1946);
    CU_ASSERT_EQUAL(ui_month, 3);
    CU_ASSERT_EQUAL(ui_days, 2);

    return;

}

int add_suite___frtds_days_fromat(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frtds_convert __frtds_days_fromat()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);
    CU_add_test(pSuite, "case4", __case4);
    CU_add_test(pSuite, "case5", __case5);

    return FR_SUCC;
}
